package com.group10.mapper;

import com.group10.entity.Blog;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface BlogMapper {

    @Select("select *from blog order by time desc")
    List<Blog> getAllBlog();

    @Select("select *from blog where user_id=#{userId} order by time desc")
    List<Blog> getUserAllBlog(String userId);

    @Insert("insert into blog(user_id,time,img,content) values(#{userId},#{time},#{img},#{content})")
    int newBlog(Blog blog);

    @Delete("delete from blog where id=#{id}")
    int deleteBlog(int id);

    @Update("update shows set like_count=like_count+1 where id=#{id}")
    int likeBlog(Integer id);
}
